package com.eve.crp;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.eve.DAObjects.GenericList;
import com.eve.DAObjects.GenericListDAO;

public class GenerateOptionList extends JdbcDaoSupport implements GenericListDAO{
	public List<GenericList> getOptionList(String tableName){
		String sql = "SELECT * FROM "+tableName+" order by `key`";
		List<Map<String, Object>> returnList = getJdbcTemplate().queryForList(sql);
		ArrayList<GenericList> genericList = new ArrayList<GenericList>();
		for(Map<String, Object> row: returnList){
			GenericList generic = new GenericList();
			generic.setKey((Long) row.get("key")); 
			generic.setValue((String) row.get("value")); 
			genericList.add(generic);
		}
		return genericList;
	}
}
